package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.entity.Staff;
import com.three.entity.Stafftransfer;
import com.three.service.StaffInfoService;
import com.three.vo.R;
import com.three.vo.StaffInfoVo;
import com.three.vo.StafftransferDiaoVo;
import jdk.nashorn.internal.objects.annotations.Optimistic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/staffInfo")
public class StaffInfoController {
    @Autowired
    private StaffInfoService staffInfoService;
    @PostMapping ("/getStaffInfo")
    @LogAnotation("获取员工信息")//日志
    public R getStaffInfo(Integer currentPage, Integer pageSize,@RequestBody StaffInfoVo staffInfoVo) {
        return staffInfoService.getStaffInfo(currentPage, pageSize,staffInfoVo);
    }

    //根据员工编号获取员工信息
    @GetMapping("checkStaffid")
    public R checkStaffid(Integer staffid){
        return staffInfoService.checkStaffid(staffid);
    }

    //根据员工身份证号获取员工信息
    @GetMapping("checkIdcard")
    public R checkIdcard(String idcard){
        return staffInfoService.checkIdcard(idcard);
    }

    //根据员工手机号获取员工信息
    @GetMapping("checkPhone")
    public R checkPhone(String phone){
        return staffInfoService.checkPhone(phone);
    }

    //添加员工信息
    @PostMapping("addStaff")
    @LogAnotation("添加员工")//日志
    public R addStaff(@RequestBody Staff staff){
        return staffInfoService.addStaff(staff);
    }
    //修改员工信息
    @PutMapping("/update")
    @LogAnotation("修改员工信息")//日志
    public R update(@RequestBody Staff staff){
        return staffInfoService.updateStaff(staff);
    }
    //数据回显
    @GetMapping("/getStaffById")
    public R getStaffById(Integer id){
        return staffInfoService.getStaffById(id);
    }
    //调动提交
    @PutMapping("/mobilizestaff")
    public R mobilizestaff(@RequestBody StafftransferDiaoVo stafftransferDiaoVo){
        return staffInfoService.mobilizestaff(stafftransferDiaoVo);
    }
    //离职
    @GetMapping("/lizhi")
    @LogAnotation("离职员工")
    public R lizhi(Integer id){
        return staffInfoService.lizhi(id);
    }
    //冻结
    @GetMapping("/freeze")
    public R freeze(Integer id){
        return staffInfoService.freeze(id);
    }


    //查询员工审核表该员工的状态
    @GetMapping("/selectStafftransferState")
    public R selectStafftransferState(Integer staffid){
        return staffInfoService.selectStafftransferState(staffid);
    }

}
